<%@ page contentType="text/html;charset=UTF-8" language="java"%>
<%
	String basePath = request.getContextPath();
	String path = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
			+ basePath + "/";
	request.setAttribute("path", path);
%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%><!doctype html>
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport"
	content="initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
<meta name="format-detection" content="telephone=no,address=no,email=no" />
<meta name="keywords" content="" />
<meta name="description" content="" />
<title>选择照片</title>
<script type="text/javascript" src="js/jquery-1.8.3.min.js"></script>
<script type="text/javascript" src="js/jquery1.12.js"></script>
<link href="css/style.css" rel="stylesheet" media="all">
<link rel="shortcut icon" href="img/favicon.png">
</head>
<body>

	<!-- header -->
	<c:choose>
		<c:when test="${empty sampleList}">
			<header class="top_header">
				<h1>
					<a href="javascript:history.go(-1);" class="go_back"></a><span>已拍摄</span>
				</h1>
			</header>
			<div class="content_wrap kamyphoto_wrap">
				<div class="kaprompt_txt">
					<img src="img/upload.png">
					<p>摄影师正在努力上传中</p>
				</div>
				<!-- kaprompt_txt -->
			</div>
		</c:when>
		<c:otherwise>
			<header class="top_header">
				<h1>
					<a href="javascript:history.go(-1);" class="go_back"></a><span>选择照片</span>
				</h1>
			</header>
			<div class="content_wrap kaselect_wrap">
				<div class="kaselect_top">
					<img src="${path}${theme.advertisingMap}" alt="选择照片">
				</div>
				<!-- kasample_txt -->
				<div class="ka_select">
					<h4>请选择需要精修的照片</h4>
					<ul>
						<c:forEach var="item" items="${sampleList}">
							<li><input name="kaselect_img_${item.id}" type="checkbox"
								id="kaselect_one_${item.id}" value="${item.id}"
								onClick="doCheck(${item.id})"> <label
								class="kaselect_lable" for="kaselect_one_${item.id}"> <span
									class="kaselect_bg"></span> <i class="kaselect_icon"></i> <a
									href="#"><img src="${path}${item.photoes}"></a>
							</label></li>
						</c:forEach>
						<div class="clear"></div>
					</ul>
				</div>
				<!-- ka_samplerel  -->
			</div>
			<!-- content_wrap -->

			<div class="kaselect_nav">
				<a onclick="selectSample()">选择</a>
			</div>
			<!-- kasampledet_nav -->
			<form id="form1" name="form1" method="post"
				action="${path}/kaSelectConfirm">
				<input id="ids" name="ids" value="${listId}" style="display: none;">
				<input id="orderId" name="orderId" value="${orderId}"
					style="display: none"> <input id="themeId" name="themeId"
					value="${theme.id}" style="display: none"> <input
					id="decoration" name="decoration" value="${theme.decoration}"
					style="display: none">

			</form>

		</c:otherwise>
	</c:choose>
	<div class="footer_copyright">
		<p>
			<span>苏州知行合一网络科技有限公司</span>提供技术支持，版权所有
		</p>
	</div>
	<!-- footer_copyright -->
	<script>
	var limit = $("#decoration").val();
	var aa;
	function doCheck(obj) {
	    var sampleId=$("#kaselect_one_"+obj).val();
		var id =$("#ids").val();
        aa=id.split(",");
		var ss="";
            if(id.indexOf(","+sampleId) > -1){
            	ss = id.replace(","+sampleId,"");
            	aa=ss.split(",");
            } else {
            	ss+=id+","+sampleId;
            }
            $("#ids").val(ss);

		aa = "";
    }
	
	function selectSample() {
		var ids = $("#ids").val();
		var idArr = ids.split(",");
		var overNum = idArr.length - 1 - limit;
		if(idArr){
			if(overNum < 0){
					alert("您还需要选择"+(-overNum)+"张照片");
					return false;
				} else if(overNum > 0){
					alert("您多选择了"+overNum+"张照片");
					return false;
				}
		}
		document.getElementById("form1").submit();
    }
		
	</script>
</body>
</html>